﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Automobile.service.BLL;
using Automobile.service.Model;
using Automobile.service.Common;
using System.Web.SessionState;

namespace Automobile.service.UI.Hander
{
    /// <summary>
    /// AddPurchase 的摘要说明
    /// </summary>
    public class AddPurchase : IHttpHandler,IRequiresSessionState
    {

        public void ProcessRequest(HttpContext context)
        {
            PurchaseBLL bll = new PurchaseBLL();
            context.Response.ContentType = "text/plain";
            Purchases p = new Purchases();
            p.Purchase_Type_State = Convert.ToInt32(context.Request["Purchase_Type_State"]);
            p.Supplier_Id = Convert.ToInt32(context.Request["Supplier_Id"]);
            p.WareHose_Id = Convert.ToInt32(context.Request["WareHose_Id"]);
            p.Employee_Id = Convert.ToInt32(context.Request["Employee_Id"]);
            p.SumMoney = Convert.ToDecimal(context.Request["SumMoney"]);
            p.Purchase_State = 0;
          string xml =context.Server.UrlDecode( context.Request.Form["xml"].ToString());  //xml解码
            context.Response.Write(bll.AddPurchase(p,xml));
            //if(bll.AddPurchase(p,xml)>0)
            //{
            //    JournalBLL jbll = new JournalBLL();
            //    jbll(Convert.ToInt32( context.Session["empid"]),p);
            //}
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}